
PROGRAM _CYCLIC
	
	MC_Home_0;
	MC_ReadActualPosition_0;
	MC_Home_1;
	MC_ReadActualPosition_1;
	MC_Home_2;
	MC_ReadActualPosition_2;
	MC_Home_3;
	MC_ReadActualPosition_3;
	
	CASE EncState OF
		W_CMD:
			IF (homing) THEN
				MC_Home_0.Execute := TRUE;
				MC_Home_1.Execute := TRUE;
				MC_Home_2.Execute := TRUE;
				MC_Home_3.Execute := TRUE;
				EncState := W_HOME_OK;
				homing := FALSE;
			END_IF	
		W_HOME_OK:
			IF (MC_Home_0.Done) AND (MC_Home_1.Done) AND (MC_Home_2.Done) AND (MC_Home_3.Done) THEN
				MC_Home_0.Execute := FALSE;
				MC_Home_1.Execute := FALSE;
				MC_Home_2.Execute := FALSE;
				MC_Home_3.Execute := FALSE;
				EncState := W_CMD;
			END_IF
	END_CASE;	

END_PROGRAM